package util

import (
	"crypto/md5"
	"fmt"
	"io"
	"time"
)

func CreateMd5(str string) string {
	w := md5.New()
	io.WriteString(w, str)
	md5Str := fmt.Sprintf("%x", w.Sum(nil))
	return md5Str
}

func GetZoneTimeFn(zoneNames ...string) time.Time {
	zoneName := "Asia/Shanghai"
	if zoneNames != nil && zoneNames[0] != "" {
		zoneName = zoneNames[0]
	}
	loc, _ := time.LoadLocation(zoneName)
	// nowTime, _ := time.ParseInLocation("2006-01-02 15:04:05", time.Now().Format("2006-01-02 15:04:05"), loc)
	time.Local = loc
	nowTime := time.Now().Local()
	return nowTime
}
